package cn.tedu._07springaop.egaop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;


@Aspect
@Component
public class CartAspect {
    @Before(value = "execution(public boolean cn.tedu._07springaop.egaop.CartServiceImpl.*(..))")
    public void beforeMethod(){
        System.out.println("[开始添加购物车]");
    }
    @After(value = "execution(public boolean cn.tedu._07springaop.egaop.CartServiceImpl.*(..))")
    public void afterMethod(){
        System.out.println("[操作完成]");
    }
    @AfterReturning(value = "execution(public boolean cn.tedu._07springaop.egaop.CartServiceImpl.*(..))",returning = "result")
    public void afterReturning(JoinPoint joinPoint,boolean result){
        if (result){
            System.out.println("[添加购物车成功]");
        }else {
            System.out.println("[添加购物车失败]");
        }
    }
}
